# Maintainer: J. Peter Mugaas <jpmugaas@suddenlink.net>

_realname=gmpy2
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=2.2.1
pkgrel=2
pkgdesc="Provides C-coded Python modules for fast multiple-precision arithmetic (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
msys2_references=(
  'archlinux: python-gmpy2'
  'purl: pkg:pypi/gmpy2'
)
msys2_repository_url='https://github.com/aleaxit/gmpy'
url='https://gmpy2.readthedocs.io/'
license=('spdx:LGPL-3.0-or-later OR GPL-3.0-or-later')
depends=(
  "${MINGW_PACKAGE_PREFIX}-gmp"
  "${MINGW_PACKAGE_PREFIX}-mpc"
  "${MINGW_PACKAGE_PREFIX}-mpfr"
  "${MINGW_PACKAGE_PREFIX}-python"
)
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-cc"
  "${MINGW_PACKAGE_PREFIX}-python-build"
  "${MINGW_PACKAGE_PREFIX}-python-installer"
  "${MINGW_PACKAGE_PREFIX}-python-setuptools"
)
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz")
sha256sums=('e83e07567441b78cb87544910cb3cc4fe94e7da987e93ef7622e76fb96650432')

build() {
  cp -r "${_realname}-${pkgver}" "python-build-${MSYSTEM}" && cd "python-build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/python -m build --wheel --skip-dependency-check --no-isolation
}

package() {
  cd "${srcdir}/python-build-${MSYSTEM}"

  MSYS2_ARG_CONV_EXCL="--prefix=" \
    ${MINGW_PREFIX}/bin/python -m installer --prefix=${MINGW_PREFIX} \
    --destdir="${pkgdir}" dist/*.whl

  install -Dm644 COPYING "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/COPYING"
  install -Dm644 COPYING.LESSER "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/COPYING.LESSER"
}
